async function toJSON(url) {
try {
let r = await fetch(url)
if (!r.ok) exception(r.status)
return r.json()
} catch (e) {
error(e)
}
}
async function readUser() {
const URL = "https://api.github.com/users/"
let u = await toJSON(URL+usr.value)
if (!u || !u.login) return
out.hidden = 0; err.hidden = 1
//start with the avatar
avatar.src = u.avatar_url
//name and location
let s = (u.name || u.login)
if (u.location) s += ', '+u.location
repoName.innerText = s; console.log(s)
//link to GitHub
let h = "github.com/"+u.login
repoLink.href = "https://"+h
repoLink.innerText = h
//repo count and repo names
let n = u.public_repos
repoCount.innerText = n
let b = n>0? await toJSON(URL+u.login+"/repos") : []
repoList.innerText = b.map(x => x.name).join(", ")
showRateLimit()
}